package fashionshop.gui.common.util;

import java.awt.Component;

import javax.swing.JOptionPane;

public class MessageBoxUtil {
	
	public static interface ConfirmDialogListener{
		void confirmCallback(int option);
	}
	
	private static final String DEFAULT_TITLE = "Fashion Shop";
	
	public static void alert(Component com, String msg){
		JOptionPane.showMessageDialog(com, msg, DEFAULT_TITLE, JOptionPane.WARNING_MESSAGE);
	}
	
	public static void info(Component com, String msg){
		JOptionPane.showMessageDialog(com, msg, DEFAULT_TITLE, JOptionPane.INFORMATION_MESSAGE);
	}
	
	public static void error(Component com, String msg){
		JOptionPane.showMessageDialog(com, msg, DEFAULT_TITLE, JOptionPane.ERROR_MESSAGE);
	}
	
	public static void confirm(Component com, String msg, ConfirmDialogListener listener){
		int rs = JOptionPane.showConfirmDialog(com, msg, DEFAULT_TITLE, JOptionPane.OK_CANCEL_OPTION);
		if(listener != null){
			listener.confirmCallback(rs);
		}
	}

}
